home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: MegaDisc
/
MegaDisc 38 (1994-02)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip
/
MegaDisc 38 (1994-02)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf
/
Tutes_&_CLI
/
PowerScripting
/
PowerScripting
Wrap
Text File
|
1994-02-14
|
9KB
|
221 lines
POWER SCRIPTING
by Paul McLachlan
38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38
The script file is one of those wonderful sections of the Amiga
that is both easy to use and wonderfully complicated. (Huh?) You
see, most users will be familiar with the most common script file -
the startup-sequence. This is also the easiest form of a script
file, a sequence of commands to be executed. There are many
advanced features that are available through scripts files, that not
only enable you to do wierd and wonderful things, but can be life
savers.
FORMATTING
Now, I've seen around, that some people have come up with the idea
of using a script to format disks. Your average format command:
Format drive df0: name "Empty" NOICONS QUICK
is quite bothersome to type in quickly. So putting this line in a
file called 'fmt0' or similar in S: and 'protect'ing it (+s) will
enable you ×to simply type:
fmt0
to quickly format the disk in df0:. All very wonderful. Now say
you have 3 disk drives. You put three of the scripts in with
slightly different names and functions, right?
Not at all. Script files allow you to enter arguments. That is,
you could (and will, by the end of this), enter, to format DF1:
fmt df1:
Now, that is a script file you're calling, and not a CLI command
that someone wrote. Lets take a look at it:
; Fmt <drive>
; Script to format the disk in the supplied drive
.bra {
.ket }
.key input
FORMAT drive {input} name "Empty" NOICONS QUICK
Interesting, huh? Lets have a little look at what some of these
lines do. Firstly, there are two lines of comments, to tell you at
a later date what this script does, and then there are another two
lines, which I have grouped together.
These two command .bra & .ket are quite important. They enable
you to choose which brackets to use for your variables. I have
chosen braces '{}'.
The next line looks good. 'input' is the name of the variable
that you want to enter. The .key command is effectively declaring
it.
The final line is the format command, with the drive replaced by
{input}, which effectively says the contents of the variable input,
or, what the user put after Fmt in the command line. This all adds
up to the ability to:
Fmt df0:
or
Fmt df1:
With one script command and some power scripting. A slight
difference to this example is the 'Wipe' command. It is pretty
similar, but shows a slight difference which may point out something
you didn't realise:
.bra {
.ket }
.key device
echo "WIPE {device}*NPress RETURN to continue, CNTRL-C to stop"
FORMAT >NIL: drive {device} name "Erased" NOICONS QUICK
Check the echo command. It actually warns you (just like the
format command would have) of which drive you are about to kill.
FILE CREATION
One of the commands I miss from my old Apple II (shame, Apple II,
shame), is the ProDOS Create command. This command 'created' an
empty file. Why is this useful? Well, I use it for various things
but mainly in testing programs and so forth. Nevertheless, it shows
an interesting aspect of the echo command.
Lets take a look at my S:Create file:
.bra {
.ket }
.key file
echo >{file} "" NOLINE
Now, the redirection of the echo command to a file is just an
application of output redirection. Output Redirection simply means
that any output that the program would generally produce is put in a
file, instead. The only type of output redirection is append, where
you:
echo >>myfile "*N"
and this appends a return to the end of the file, while:
echo >myfile "*N"
would erase the file and make a new one that has just a return in
it.
I used to use the append output redirection as a type of log. In
my startup sequence I would have a command sequence:
echo >>S:Logfile "*NStartup executed " NOLINE
date >>S:Logfile
and this would write startup executed and the date everytime to a
logfile that gradually got larger and larger until I deleted it.
USING THE LIST COMMAND
This command is a powerful script command, although it sometimes
takes a while for people to realise it. It is the list 'LFORMAT'
option that makes the list command so powerful.
My example for this command comes from the days when I ran a BBS.
Whenever a batch of new Fish disks came in, I had to archive the
whole lot and copy it onto the harddrive. This, quite naturally,
became a tedious procedure. To start with, lets take a look at the
format of a standard fish disk. Say, #601:
PP (dir)
Docs (dir)
Copyright.DOC Copyright.DOC.info
PP.DOC PP.DOC.info
PP.history PP.history.info
Shareware.ANGER! Shareware.ANGER!.info
Docs.info PP
PP.info ReadMe.fnf
Source.lzh
APipe (dir)
APipe-Handler APipe-Handler_rev.h
APipe-Handler_rev.i APipe-Handler_rev.rev
child.asm Makefile
Mountlist pgmpipe.c
README README.fnf
README.info POSTER
c (dir)
MuchMore XIcon
Intuisup (dir)
Texts (dir)
.info source.lzh
texts_test texts_test.info
Borders.info Editor.info
Files.info Gadgets.info
InstallLibrary InstallLibrary.info
Language.info Library.info
Menus.info Pointer.info
ReadMe ReadMe.fnf
ReadMe.info Render.info
Requester.info Texts.info
APipe.info Catalog
Catalog.info Contents
Contents.info Disk.info
Distribution Distribution.info
Intuisup.info Orders
Orders.info PP.info
ReadMeFirst ReadMeFirst.info
Submissions Submissions.info
Now, this is a pretty standard directory listing, and all fish
disks follow the same format. I had to devise a script file that
would create archives called PP.lha, APipe.lha and Intuisup.lha, and
put into them the contents of those directories. Another couple of
things to be noted: Sometimes directories contain a readme.fnf file
or a POSTER. These files are unnecessary for the BBS, and so I am
not going to archive them.
Take a look at this script file:
; This batch file archives all the directories on the internal
; disk into separate archives for each - to the current directory.
list >RAM:a.script df0:~C dirs LFORMAT="LHA -r -x a %N.LHA %P%N/#?"
echo "Archiving Files.... Please wait"
execute ram:a.script
echo "All DONE!"
Now, isn't that clever. (You may need to consult your AmigaDOS
manual for the uses of all the %P's and so on in the LFORMAT string)
Finally, to finish off the tutorial, on your workbench disk, load
up the S:SPat script file. This adds pattern matching to commands
that do not normally support it. It uses most of the techniques I
have described above.
38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38 *^* 38